package database.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name = "card", uniqueConstraints = {@UniqueConstraint(columnNames={"uid"})})
public class AuthCardData {
	
	@Id
	@Column(name = "uid")
	private String card_uid;
	
	@Column(name = "card_key", nullable = false)
	private String card_key;
	
	@Column(name = "saltForPin1", nullable = false)
	private String card_saltForPin1;
	
	@Column(name = "pin2", nullable = false)
	private String card_pin2;
	
	@Column(name = "ctc2", nullable = false)
	private String card_ctc2;
	
	@Column(name = "otp", nullable = false)
	private String card_otp;
	
	@Column(name = "password", nullable = false)
	private String card_password;
	
	@OneToOne(mappedBy = "card")
	private User user;
	
	
	/**
	 * Constructeur vide.
	 */
	public AuthCardData() {}
	
	/**
	 * Créé une nouvelle AuthCardData.
	 * @param uid : UID de la card
	 */
	public AuthCardData(String uid) {
		this.card_uid = uid;
	}
	
	/**
	 * Créé une nouvelle AuthCardData.
	 * @param uid : UID de la card
	 * @param key : clé aléatoire stockée dans USER1 de la card
	 * @param salt_pin1 : sel servant au pin1 de la car
	 * @param salt_password : sel servant au password final de la card
	 * @param pin2 : PIN2 de la card
	 * @param otp : password à usage unique de la card
	 * @param password : mot de passe final de la card
	 */
	public AuthCardData(String uid, String key, String salt_pin1, String pin2, 
			String ctc2, String otp, String password) {
		this.card_uid = uid;
		this.card_key = key;
		this.card_saltForPin1 = salt_pin1;
		this.card_pin2 = pin2;
		this.card_ctc2 = ctc2;
		this.card_otp = otp;
		this.card_password = password;
	}

	public String getCard_uid() {	return card_uid;	}
	public void setCard_uid(String card_uid) {	this.card_uid = card_uid;	}
		
	public String getCard_key() {	return card_key;	}
	public void setCard_key(String card_key) {	this.card_key = card_key;	}
	
	public String getCard_saltForPin1() {	return card_saltForPin1;	}
	public void setCard_saltForPin1(String card_saltForPin1) {	this.card_saltForPin1 = card_saltForPin1;	}

	public String getCard_pin2() {	return card_pin2;	}
	public void setCard_pin2(String card_pin2) {	this.card_pin2 = card_pin2;	}

	public String getCard_ctc2() {	return card_ctc2;	}
	public void setCard_ctc2(String card_ctc2) {	this.card_ctc2 = card_ctc2;	}

	public String getCard_otp() {	return card_otp;	}
	public void setCard_otp(String card_otp) {	this.card_otp = card_otp;	}

	public String getCard_password() {	return card_password;	}
	public void setCard_password(String card_password) {	this.card_password = card_password;	}
	
	public User getUser() {	return user;	}
	public void setUser(User user) {	this.user = user;	}
	

	public String toString() { return this.card_uid; }
}
